const request = uni.$u.http
//展示数据相关
export const reqAttrLisstData = (page, arr) => request.get(`/api/index?page=${page}&sales=${arr[0]}&recommend=${arr[1]}&new=${arr[2]}`)


//登录相关	
export const reqLoginStatus = parmars =>  request.post('/api/auth/login', parmars)


export const reqUserData = () =>  request.get('/api/user')


export const reqRigser = data =>request.post('/api/auth/register',data)



export const reqChangName = name =>  request.put('/api/user',{name})


export const reqQuitLogin = () => request.post('/api/auth/logout')


export const reqOSSToken = () =>  request.get('/api/auth/oss/token')

export const reqSaveImgOss = parmers => request.post('https://laravel-book-shop.oss-cn-beijing.aliyuncs.com/',parmers)

export const reqChangUserImg = avatar =>  uni.$u.patch('/api/user/avatar',{avatar})

export const reqRequsetDetial = id => request.get(`/api/goods/${id}`)

export const reqHaveAttr = id => request.post(`/api/collects/goods/${id}`)

export const reqPushShopCart = (data) => request.post('/api/carts',data)

export const reqShopCartList = () => request.get('/api/carts?include=goods')

export const reqListGoodsData = (params={}) => request.get('/api/goods',{params})

export const reqChangeCarNum = (cart,parms) => request.put(`/api/carts/${cart}`,parms)

export const reqChangeSclict = (arr) => uni.$u.patch('/api/carts/checked',{cart_ids:arr})

export const reqDelectCar = (cart) => request.delete(`/api/carts/${cart}`)

export const reqOrdersDetial = () => request.get('/api/orders/preview')

export const reqPayOrder = (order) => request.get(`/api/orders/${order}/pay`)

export const reqSetDefultAddress = (address) => uni.$u.patch(`/api/address/${address}/default`)

export const reqNewAddress = (parms) => request.post('/api/address',parms)

export const reqDelAddress = (address) => request.delete(`/api/address/${address}`)

export const reqPayData = (order) => request.get(`/api/orders/${order}/pay?type=aliyun`,)

export const reqSumbitOreder = (address) => request.post('/api/orders',address)

//不可抗力原因支付无法完成 故此接口不考虑使用
export const reqPayStatus = (order) => request.get(`/api/orders/${order}/status?type=aliyun`,)

export const reqOrderList = ({page,title}) => request.get(`api/orders?include=orderDetails.goods&page=${page}&title=${title}`)
